package com.streetlight.lampcursor.ui.schedule

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.streetlight.lampcursor.model.ScheduleData
import com.streetlight.lampcursor.repository.StreetLightRepository
import kotlinx.coroutines.launch

class ScheduleViewModel : ViewModel() {

    private val repository = StreetLightRepository()

    private val _schedules = MutableLiveData<List<ScheduleData>>()
    val schedules: LiveData<List<ScheduleData>> = _schedules

    fun loadSchedules() {
        viewModelScope.launch {
            try {
                val scheduleList = repository.getSchedules()
                _schedules.value = scheduleList
            } catch (e: Exception) {
                // 处理错误
            }
        }
    }

    fun addNewSchedule() {
        // 添加新定时的逻辑
    }
} 